﻿using System;

public class AlarmClock
{
    public event EventHandler Tick;
    public event EventHandler Alarm;

    public void Start()
    {
        while (true)
        {
            OnTick();
            System.Threading.Thread.Sleep(1000); // 模拟嘀嗒间隔

            // 假设当秒数为10时触发闹钟响铃事件
            if (DateTime.Now.Second == 10)
            {
                OnAlarm();
                break;
            }
        }
    }

    protected virtual void OnTick()
    {
        Tick?.Invoke(this, EventArgs.Empty);
    }

    protected virtual void OnAlarm()
    {
        Alarm?.Invoke(this, EventArgs.Empty);
    }
}

public class Program
{
    static void Main(string[] args)
    {
        AlarmClock alarmClock = new AlarmClock();

        alarmClock.Tick += (sender, e) =>
        {
            Console.WriteLine("嘀嗒...");
        };

        alarmClock.Alarm += (sender, e) =>
        {
            Console.WriteLine("闹钟响铃！");
        };

        alarmClock.Start();
    }
}
